//
//  AppointmentController.m
//  HarmonizePub
//
//  Created by rzhy on 16/8/24.
//  Copyright © 2016年 Zy. All rights reserved.
//


/**
 * 你好！我是Zy，这个项目头号挖坑人.
 * 当你看到这段留言时，说明你来到了"预约挂号"功能.
 * 那么，接下来，我要恭喜你了，你的噩梦从此开始，相信我.
 * 如果，你接到的需求是要修改这个功能的某个地方.
 * 那么，你该开始找工作了...
 *  (当你完整看完这个功能时，你会明白的，祝你工作愉快!)
 */


#import "AppointmentController.h"
#import "Config.h"
#import "AppointmentTableView.h"
#import "SchedulingController.h"
#import "User.h"

@interface AppointmentController () <AppointmentTableViewDelegate>
{
    NSArray *_dataArray;
}
@property (weak, nonatomic) IBOutlet AppointmentTableView *leftTableView;


@end

@implementation AppointmentController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
//    self.title = @"预约挂号";
   
    self.leftTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.leftTableView.backgroundColor = [UIColor whiteColor];
    [self getDepList];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)getDepList {
    __weak typeof(self) weakSelf = self;
    [HTTPSTool GETRequestWithPath:XHGetOrderDpPath params:nil success:^(NSDictionary * _Nonnull JSON) {
//        LRLog(@"预约挂号科室列表 -> JSON: %@", JSON)
        _dataArray = JSON[@"data"][@"list"];
        [weakSelf.leftTableView reloadData];
    }];
}

#pragma mark - tableView delegate/dataSource Method
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 55.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.backgroundColor = [UIColor clearColor];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.textLabel.textColor = RGBColor(232, 154, 190);
        cell.textLabel.font = [UIFont systemFontOfSize:15.0f];
        cell.textLabel.numberOfLines = 0;
    }
    cell.textLabel.text = _dataArray[indexPath.row][@"ksmc"];;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.view endEditing:NO];
    SchedulingController *scheduling = [[SchedulingController alloc] init];
    scheduling.selectDataDict = _dataArray[indexPath.row];
    [self.navigationController pushViewController:scheduling animated:YES];
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:NO];
}

@end
